home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: HTML
- Sub-category: ComboBoxes
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This stylsheet demonstrates how to load the contents of an
- HTML combo box as well as setting the default value. In
- this example, we store the default value in a variable to
- make the code a bit more reusable.Also note that we are
- using the Pull method to extract data from our xml document.
- The pull method is an approach where the use of templates is
- minimized and data is accessed by "pulling" it
- from our xml document
- ================================================================ -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN" />
-
- <xsl:template match="/">
- <html>
- <head>
- <style type="text/css">
- H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
- TD {COLOR: darkblue; FONT-FAMILY: Arial}
- TR { background-color: beige; }
- BODY { background-color: beige; }
- </style>
- </head>
- <body>
- <span class="subhead">Loading an HTML combo box from xml (Using the Pull approach)</span>
- <br />
- <xsl:variable name="cmbDefault" select="'AROUT'" />
- <SELECT id="cmbCompanies" name="cmbCompanies">
- <xsl:for-each select="customers/customer">
- <xsl:element name="OPTION">
- <!--Make sure that the default value is highlighted -->
- <xsl:if test="@CustomerID = $cmbDefault">
- <xsl:attribute name="selected" />
- </xsl:if>
- <!-- Set the value for the combo box -->
- <xsl:value-of select="@CompanyName" />
- </xsl:element>
- </xsl:for-each>
- </SELECT>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>